home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.07 Jul 90 / C++ micro-Draw ƒ / DisplList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-21  |  1.9 KB  |  77 lines  |  [TEXT/MPS ]

  1. class TDisplObj {
  2.   private:
  3.     Boolean HiLiteState;    // true : highlighted
  4.   protected:
  5.     TDisplObj(Rect r);        // Only accessible to public descendants
  6.     Rect fBoundRect;
  7.     Pattern fObjPat;
  8.   public:
  9.     virtual void Draw(Pattern)     {DebugStr("\pCall to TDisplObj::Draw");}
  10.     virtual void Erase()          {DebugStr("\pCall to TDisplObj::Erase");}
  11.     virtual void DoContent()      {DebugStr("\pCall to TDisplObj::DoContent");}
  12.     virtual void DoIdle() { /* do nothing by default*/ }
  13.     Rect GetBoundRect() {return fBoundRect;}
  14.     void SetBoundRect(Rect theRect) {fBoundRect = theRect;}
  15.     Pattern GetObjPat() {return fObjPat;}
  16.     void SetObjPat(Pattern pat); 
  17.     void DragObj(Point*, Rect); 
  18. };
  19.  
  20. class TObjLink {
  21.     friend class TObjList;
  22.  
  23.     TObjLink*    fNext;    // the link to the next object
  24.     TDisplObj*    fmyObj;    // the object this link refers to
  25.  
  26.     // our constructor can take args for convenience;
  27.     // they default to nil.
  28.     TObjLink(TObjLink *n = nil, TDisplObj *v = nil);
  29.   public:
  30.     inline TObjLink*    GetNext() { return fNext; };
  31.     inline TDisplObj*     GetmyObj() { return fmyObj; };
  32.     inline void            SetNext(TObjLink* aLink) { fNext = aLink; };
  33.     inline void         SetmyObj(TDisplObj* aObj) { fmyObj = aObj; };
  34. };
  35.  
  36. class TObjList {
  37.     TObjLink*    fHeader;    // the first link in our list
  38.     int            fNumObjs;    // the number of elements in the list
  39.  
  40. public:
  41.     TObjList(void);  ~TObjList(void);
  42.     
  43.     inline TObjLink* Header() { return fHeader; }
  44.     inline int        NumObjs() { return fNumObjs; }
  45.  
  46.     void        AddObj(TDisplObj* obj);
  47.     void        RemoveObj(TDisplObj* obj);
  48.     TDisplObj*    FindObj(Point theLoc);
  49. };
  50.  
  51.  
  52. class TRoundRect : public TDisplObj {
  53.   public:
  54.     TRoundRect(Rect r);
  55.      virtual void Draw(Pattern);
  56.     virtual void Erase();
  57.   private:
  58.     short fOvalWidth, fOvalHeight;        // curvature of rounded corners 
  59. };
  60.  
  61.  
  62. class TOval : public TDisplObj {
  63.   public:
  64.     TOval(Rect r);
  65.     virtual void Draw(Pattern);
  66.     virtual void Erase();
  67. };
  68.  
  69.  
  70. class TRect : public TDisplObj {
  71.   public:
  72.     TRect(Rect r);
  73.     virtual void Draw(Pattern);
  74.     virtual void Erase();
  75. };
  76.  
  77.